<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Featured</title>
</head>
<body>
<div id="wishlist-body">

	<?php
require 'connect.php';

$sql = "SELECT property_id FROM featuredlists";
$result_featured_lists = mysqli_query($conn, $sql);

	if (mysqli_num_rows($result_featured_lists) > 0){

		while($row = mysqli_fetch_assoc($result_featured_lists)){

		//echo print_r($row),"<br>";			///displaying for debuging purposes only 

 			$sql = "SELECT bedrooms, price, description, suburb, city, street_name, street_number, properties.id FROM properties 
					INNER JOIN addresses ON addresses.property_id = properties.id
					WHERE properties.id = ".$row['property_id'];

			$result = mysqli_query($conn, $sql);

//		echo print_r ($result);				///displaying for debuging purposes only 

			if (mysqli_num_rows($result) > 0){

				$property_data = mysqli_fetch_assoc($result);
		

				//getting photos urls or current property
				$sql = "SELECT photo_url FROM photos WHERE photos.property_id = ".$property_data['id'];
				$result_photos = mysqli_query($conn, $sql);
				if (mysqli_num_rows($result_photos) > 0){ ?>

					<div>
					<?php $current_property_photo_urls = mysqli_fetch_assoc($result_photos);
					//echo ($current_property_photo_urls['photo_url']);////displaying for debuging purposes only
					$photoUrl = './'.$current_property_photo_urls['photo_url'];
					?>
				</div>
				<section class="search-results-body">
					<div class="column one-half">
				        <div class="col-group dis-card">
				          <div class="img-container">
				            <img src="<?php echo $photoUrl;?>" class="house-img" width="300px" height="200px">
				          </div>
				          <h2 class="house-title"><?php echo $property_data['street_number']. ' '.$property_data['street_name']. ', '.$property_data['suburb']. ', '.$property_data['city']  ?></h2>
				          <div class="bedroom-wrapper">
						  	<span class="house-price"><?php echo '$'.number_format($property_data['price']); ?></span>
				            <span class="bed-number"><?php echo $property_data['bedrooms'] ?></span>
				            <img src="WebsiteImg/bed.png" class="bed-img">
				          </div>
						  <p class="desc-text-cards"><?php echo $property_data['description'] ?></p>
				        </div>
				      </div>
				</section>


<?php
				}
			}			
		}
	}				
?>
	
</div>
</body>
</html>
